/*
package com.winning.sjzc.common.config;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;

*/
/**
 * description: 登录过滤器
 *
 * @author yanxf@winning.com.cn
 * @date 2019/08/27 10:01
 *//*


@WebFilter(filterName = "loginFilter", urlPatterns = "/*")
public class LoginFilter implements Filter {

  private String[] whiteList = null;

  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    whiteList = new String[]{"/index"};
  }

  @Override
  public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;
    if (shouldFilter(request)) {
      String username = (String) request.getSession().getAttribute("loginUsername");
      if (StringUtils.isEmpty(username)) {
        ((HttpServletResponse) resp).sendRedirect( "/sjzc/login");
        return;
      }
    }
    chain.doFilter(req, resp);
  }

  @Override
  public void destroy() {

  }

  protected boolean shouldFilter(HttpServletRequest request)
      throws ServletException {

    String path = request.getServletPath();
    if (null != whiteList && whiteList.length > 0) {
      for (String url : whiteList) {
        if ((path.equals(url))) {
          return true;
        }
      }
    }
    return false;
  }
}
*/
